﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Threading.Tasks;
using System.Web.Mvc;
using ZFine.Application.Project;
using ZFine.Code;
using ZFine.Domain.Entity;
using System.Linq;
using System.Web;
using Logiv.WEB.Areas.Project.Controllers;
using ZFine.Application.SystemManage;
using ZFine.Web;

namespace Logiv.WEB.Areas.Project.Controllers
{
    public class InformMessagesController : BaseController
    {
        private InformMessagesApp serviceapp = new InformMessagesApp();

        public ActionResult Index1()
        {
            return View();
        }
        public ActionResult Form1()
        {
            return View();
        }
        #region 商户-消息
        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetGridJson(Pagination pagination, string keyword)
        {
            try
            {
                var data = new
                {
                    rows = serviceapp.GetList(pagination, keyword),
                    total = pagination.total,
                    page = pagination.page,
                    records = pagination.records
                };
                return Content(data.ToJson());

            }
            catch (Exception ex)
            {
                return null;
            }
        }
        [HttpPost]
        [HandlerAjaxOnly]
        [ValidateInput(false)]
        public ActionResult SubmitFormC(InformMessagesEntity NewsEntity)
        {
            serviceapp.SubmitFormC(NewsEntity);
            return Success("操作成功。");
        }
        #endregion

        #region 会员-消息
        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetGridJsonM(Pagination pagination, string keyword)
        {
            try
            {
                var data = new
                {
                    rows = serviceapp.GetListM(pagination, keyword),
                    total = pagination.total,
                    page = pagination.page,
                    records = pagination.records
                };
                return Content(data.ToJson());

            }
            catch (Exception ex)
            {
                return null;
            }
        }

        [HttpPost]
        [HandlerAjaxOnly]
        [ValidateInput(false)]
        public ActionResult SubmitFormM(InformMessagesEntity NewsEntity)
        {
            serviceapp.SubmitFormM(NewsEntity);
            return Success("操作成功。");
        }
        #endregion

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="keyValue"></param>
        /// <returns></returns>
        public ActionResult GetFormJson(string keyValue)
        {
            var date = serviceapp.GetForm(keyValue);
            return Content(date.ToJson());
        }
        [HttpPost]
        [HandlerAjaxOnly]
        [HandlerAuthorize]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteForm(string keyValue)
        {
            serviceapp.DeleteForm(keyValue);
            return Success("删除成功。");
        }
    }

}
